package app.cn.com.school.activity

import android.content.Context
import android.os.Bundle
import android.support.v4.app.Fragment
import app.cn.com.school.R
import app.cn.com.school.adapter.MyViewPagerAdapter
import app.cn.com.school.databinding.ActivityNewsBinding
import app.cn.com.school.fragment.NewsFragment
import app.cn.com.school.tools.Constants

class NewsActivity : BaseActivity<ActivityNewsBinding>() {
    override fun initBindingVar() {
    }

    override fun initTitle() {
        binding.newsBack.setOnClickListener { finish() }
    }

    private var fragemnts = ArrayList<Fragment>()
    private val titles = arrayOf("订单消息", "系统消息")
    lateinit var context: Context
    private var adapter: MyViewPagerAdapter? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initBinding(R.layout.activity_news)
        context = this
        initView()
    }

    private fun initView() {
        fragemnts.add(NewsFragment().newInstance(1))
        fragemnts.add(NewsFragment().newInstance(2))
        adapter = MyViewPagerAdapter(supportFragmentManager, fragemnts, titles)
        binding.newsViewpager.adapter = adapter
        binding.newsTab.setupWithViewPager(binding.newsViewpager)
        binding.newsTab.setTabsFromPagerAdapter(adapter)
        binding.newsTab.post { Constants.setIndicator(binding.newsTab, 50, 50) }
    }

}
